package com.activenetwork.smlite.testcase.sourcing.RFP_Basics.f01_New_RFP_Basic.f02_RFP_Name;

import javax.xml.datatype.DatatypeConfigurationException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.activenetwork.custom.uielement.UIElement;
import com.activenetwork.custom.uielement.decorate.IdentifierFactory;
import com.activenetwork.smlite.page.event.EventDetailView.EventSourceSubview;
import com.activenetwork.smlite.page.event.EventDetailView.EventSummarySubview;
import com.activenetwork.smlite.page.rfp.RfpMaintenanceView.RfpSetting;
import com.activenetwork.smlite.testcase.BaseCase;
import com.activenetwork.smlite.testcase.sourcing.RfpCaseEvent;
import com.activenetwork.util.EnvContext;
import com.activenetwork.util.PageLoader;
import com.activenetwork.util.nexuserror.NexusErrors;
import com.activenetwork.util.verification.gson.FailureAssertion;
import com.activenetwork.util.verification.gson.FailurePoint;

public class RfpName002 extends BaseCase {
	static final Logger logger = LoggerFactory.getLogger(RfpName002.class);
	private RfpCaseEvent rfpCaseEvent;
	
	@BeforeClass(alwaysRun = true)
	public void dataSetup() throws DatatypeConfigurationException {	
		rfpCaseEvent = new RfpCaseEvent();
	}
	
	@Test
	public void Veify_RFP_name_is_a_mandatory_field(){
		loginBusiness.login();
		
		// Create the rfp case needed event if necessary
		rfpCaseEvent.createRfpCaseEvent();
		EventSummarySubview eventSummarySubview = PageLoader.load(EventSummarySubview.class);
		EventSourceSubview eventSourceSubview = eventSummarySubview.navigateSourcing();
		RfpSetting rfpSetting = eventSourceSubview.clickAddRfp();
		
		logger.info("Verify going to next step without filling rfp name");
		UIElement rfpNameInput = IdentifierFactory.createUIElement("RfpSetting", "rfpName");
		rfpNameInput.clear();
		rfpSetting.clickNext();
		
		NexusErrors errors = new NexusErrors("nexus-errors-RfpBasicsSubview");
		if(!errors.isErrorDisplay()){
			EnvContext.failurePointTL.get().add(new FailurePoint(
					RfpName002.class.getName(), 
					"Verify rfp name is mandatory", 
					"Unable to find the error msg when rfp name is not set"));
		}
		
		rfpSetting.clickCancel();
		loginBusiness.logout();
		FailureAssertion.pop(RfpName002.class);
		
	}
}
